﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _1.OrderService
{
    public partial class SortForm : Form
    {
        Form1 _form1;
        OrderService _orderService;
        AutoSizeFormClass asc = new AutoSizeFormClass();
        public SortForm(Form1 form1,OrderService orderService)
        {
            InitializeComponent();
            _form1 = form1;
            _orderService = orderService;
            this.SizeChanged += Form_SizeChanged;
        }

        private void button_quit_Click(object sender, EventArgs e)
        {
            _form1.Show();
            this.Close();
        }

        private void button_ById_Click(object sender, EventArgs e)
        {
            _orderService.orders.Sort((x, y) => x.CompareByOrderID(y));
            DialogResult dr = MessageBox.Show("修改排序方式成功", "提示", MessageBoxButtons.OK);
        }

        private void button_ByProduct_Click(object sender, EventArgs e)
        {
            _orderService.orders.Sort((x, y) => x.CompareByProduct(y));
            DialogResult dr = MessageBox.Show("修改排序方式成功", "提示", MessageBoxButtons.OK);
        }

        private void button_ByCustom_Click(object sender, EventArgs e)
        {
            _orderService.orders.Sort((x, y) => x.CompareByCustomer(y));
            DialogResult dr = MessageBox.Show("修改排序方式成功", "提示", MessageBoxButtons.OK);
        }

        private void button_ByMoney_Click(object sender, EventArgs e)
        {
            _orderService.orders.Sort((x, y) => x.CompareByAmount(y));
            DialogResult dr = MessageBox.Show("修改排序方式成功", "提示", MessageBoxButtons.OK);
        }

        private void SortForm_Load(object sender, EventArgs e)
        {
            asc.controllInitializeSize(this);
        }

        private void Form_SizeChanged(object sender, EventArgs e)
        {
            asc.controlAutoSize(this);
        }
    }
}
